package chapter67;

/*
 * 商品类
 */

public abstract class Goods {
	//打印商品价格的方法
	public abstract void printPrice();
}

//打印电视机的价格
class Tv extends Goods{
	public void printPrice(){
		System.out.println("电视的价格是2000元");
	}
}

class Foods extends Goods{
	public void printPrice(){
		System.out.println("食品的价格是300元");
	}
}

class Computer extends Goods{
	public void printPrice(){
		System.out.println("电脑的价格是5000");
	}
}

/**
 * 工厂类
 * 生产给商场商品
 */
class Factory{
	//生产商品给商场
	public Goods produceGoods(String type){
		Goods goods = null;
		if(type.equals("Tv")){
			goods = new Tv();
		}else if(type.equals("foods")){
			goods = new Foods();
		}else{
			goods = new Computer();
		}
		return goods;
	}
}

